package com.seu.clab.farm.controller;

import com.seu.clab.farm.common.annotation.WebResponse;
import com.seu.clab.farm.common.cos.QCloudCOSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@WebResponse
@RestController
@CrossOrigin
public class CommonController {

    @Autowired
    QCloudCOSClient qCloudCOSClient;

    @PostMapping("/uploadFile")
    public Object uploadFile(
            @RequestParam(name = "file") MultipartFile multipartFile
    ) throws IOException {
        String fileUrl = qCloudCOSClient.uploadFile(multipartFile);
        return fileUrl;
    }


}